<?php
// 声明学生信息变量
$name = "张三"; // 字符串数据类型
$age = 20; // 整数数据类型
$gpa = 3.5; // 浮点数据类型
$isGraduated = false; // 布尔数据类型

// 用于存储多个学生信息的数组数据类型
$students = array(
    array("name" => "张三", "age" => 20, "gpa" => 3.5, "isGraduated" => false),
    array("name" => "李四", "age" => 22, "gpa" => 3.8, "isGraduated" => true),
);

 
// 创建一个学生对象
$student = new stdClass();
$student->name = "王五";
$student->age = 21;
$student->gpa = 3.6;
$student->isGraduated = false;


// 显示学生信息
echo "学生姓名: " . $name . "<br/>";
echo "年龄: " . $age . "<br/>";
echo "学分绩: " . $gpa . "<br/>";
echo "毕业: " . ($isGraduated ? "是" : "否") . "<br/><br/><br/>";

// 显示所有学生信息
foreach ($students as $student) {
    echo "学生姓名: " . $student["name"] . "<br/>";
    echo "年龄: " . $student["age"] . "<br/>";
    echo "学分绩: " . $student["gpa"] . "<br/>";
    echo "毕业: " . ($student["isGraduated"] ? "是" : "否") . "<br/><br/><br/>";
}

 
// 显示学生对象中的学生信息
echo "学生姓名: " . $student->name . "<br/>";
echo "年龄: " . $student->age . "<br/>";
echo "学分绩: " . $student->gpa . "<br/>";
echo "毕业: " . ($student->isGraduated ? "是" : "否") . "<br/><br/><br/>";


?>
